package jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * @classname:JdbcCont
 * @description:
 * @author: Mr.Z
 * @date: 2020/12/26 17:15
 * @version: 0.1
 * @since:1.8
 */
public class JdbcCont {
    public static void main(String[] args) {
        for (int i = 0; i < 3; i++) {
            JdbcCont connection = new JdbcCont();
            new Thread(()->{
                for (int i1 = 0; i1 < 3; i1++) {
                    System.out.println(Thread.currentThread().getName()+"==="+connection.getCon());
                }
            }).start();
            
        }

    }



    public static Connection getCon(){
        Connection connection = null;
        String username = "root";
        String password = "root";
        String path = "com.mysql.jdbc.Driver";
        String driver ="jdbc:mysql://192.168.12.250:3306/homework?useSSL=true&characterEncoding=utf-8";
        try {
            Class.forName(path);
             connection = DriverManager.getConnection(driver,  username,password);

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return connection;

    }
}
